package br.com.agiledev.webscrum.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@SequenceGenerator(name = "dailyscrum", sequenceName = "se_dailyscrum")
@NamedQueries ({
    @NamedQuery(name = "DailyScrum.porSprintData", query = "select ds from DailyScrum ds where ds.sprint = :sprint and ds.dataReuniao = :dataReuniao"),
    @NamedQuery(name = "DailyScrum.porSprint", query = "select ds from DailyScrum ds where ds.sprint = :sprint order by ds.dataReuniao asc"),
    @NamedQuery(name = "DailyScrum.porRelease", query = "select ds from DailyScrum ds where ds.sprint.release = :release order by ds.dataReuniao asc")
})
public class DailyScrum implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "dailyscrum")
    private Long oid;
    
    @Temporal(TemporalType.DATE)
    @Column(nullable = false)
    private Date dataReuniao;
    
    @ManyToOne(optional = false, cascade = {CascadeType.REMOVE}, fetch = FetchType.LAZY)
    private Sprint sprint;

    @Column(nullable = false, precision = 2)
    private Double trabalhoPlanejado;
    
    @Column(nullable = false, precision = 2)
    private Double trabalhoAndamento;
    
    @Column(nullable = false, precision = 2)
    private Double trabalhoFinalizado;
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "dailyScrum", cascade = {CascadeType.REMOVE})
    private List<Impediment> impedimentos;
    
    public DailyScrum() {
    }
    
    public DailyScrum(Sprint sprint, Date data) {
	setSprint(sprint);
	setDataReuniao(data);
    }

    public Long getOid() {
	return this.oid;
    }

    public void setOid(Long oid) {
	this.oid = oid;
    }

    public Date getDataReuniao() {
        return dataReuniao;
    }

    public void setDataReuniao(Date dataReuniao) {
        this.dataReuniao = dataReuniao;
    }

    public Sprint getSprint() {
        return sprint;
    }

    public void setSprint(Sprint sprint) {
        this.sprint = sprint;
    }

    public Double getTrabalhoPlanejado() {
        return trabalhoPlanejado;
    }

    public void setTrabalhoPlanejado(Double trabalhoPlanejado) {
        this.trabalhoPlanejado = trabalhoPlanejado;
    }

    public Double getTrabalhoAndamento() {
        return trabalhoAndamento;
    }

    public void setTrabalhoAndamento(Double trabalhoAndamento) {
        this.trabalhoAndamento = trabalhoAndamento;
    }

    public Double getTrabalhoFinalizado() {
        return trabalhoFinalizado;
    }

    public void setTrabalhoFinalizado(Double trabalhoFinalizado) {
        this.trabalhoFinalizado = trabalhoFinalizado;
    }

    public List<Impediment> getImpedimentos() {
        return impedimentos;
    }

    public void setImpedimentos(List<Impediment> impedimentos) {
        this.impedimentos = impedimentos;
    }

}
